<!DOCTYPE html>
<html>

<head>
    <base href="{#location.origin#}/res/smartadmin-402/" />
    <meta charset="utf-8">
    <title>
        {#data.respool_id ? '编辑' : '添加'#}资源池 - {#uim.config.app_name#}
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, minimal-ui">
    <!-- Call App Mode on ios devices -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- Remove Tap Highlight on Windows Phone IE -->
    <meta name="msapplication-tap-highlight" content="no">
    <!-- base css -->
    <link rel="stylesheet" media="screen, print" href="css/vendors.bundle.css">
    <link rel="stylesheet" media="screen, print" href="css/app.bundle.css">
    <!-- Optional: page related CSS-->
</head>

<body>
    {#include template="include/page-settings"/#}
    <!-- BEGIN Page Wrapper -->
    <div class="page-wrapper alt">
        <!-- BEGIN Page Content -->
        <!-- the #js-page-content id is needed for some plugins to initialize -->
        <main id="js-page-content" role="main" class="page-content">
            <ol class="breadcrumb page-breadcrumb">
                <li class="breadcrumb-item">资源池管理</li>
                <li class="breadcrumb-item active">{#data.respool_id ? '编辑' : '添加'#}资源池</li>
            </ol>

            <div class="row">
                <div class="col-xl-12">
                    <div id="panel-6" class="panel">
                        <div class="panel-hdr">
                            <h2>
                                添加资源池
                            </h2>
                        </div>
                        <div class="panel-container show">
                            <form class="needs-validation" novalidate autocomplete="off">
                                <input type="hidden" name="respool_id" value="{#data.respool_id || ''#}">
                                <div class="panel-content">
                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            资源池名称</label>
                                        <div class="col-12 col-lg-6 ">
                                            <input type="text" class="form-control" name="respool_name"
                                                value="{#data.respool_name || ''#}" placeholder="资源池名称" required>
                                            <div class="invalid-tooltip">
                                                资源池名称不能为空！
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            资源池配置</label>
                                        <div class="col-12 col-lg-6 ">
                                            <div class="frame-wrap mt-2">
                                                <div class="custom-control custom-checkbox custom-control-inline">
                                                    <input type="checkbox" class="custom-control-input" id="auto_deploy"
                                                        {#data.auto_deploy ? 'checked' : ''#}>
                                                    <label class="custom-control-label" for="auto_deploy">自动化部署</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row need_auto_deploy">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            资源池接口</label>
                                        <div class="col-12 col-lg-6 ">
                                            <input type="text" maxlength="200" class="form-control" name="respool_api"
                                                value="{#data.respool_api || ''#}"
                                                placeholder="http[s]://respool.xxx.xxx/" required disabled>
                                            <div class="invalid-tooltip">
                                                请填写资源池接口！
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row need_auto_deploy">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            资源池账号</label>
                                        <div class="col-12 col-lg-3 ">
                                            <input type="text" maxlength="50" class="form-control" name="respool_account"
                                                value="{#data.respool_account || ''#}" placeholder="id / account"
                                                required disabled>
                                            <div class="invalid-tooltip">
                                                请填写资源池账号！
                                            </div>
                                        </div>
                                        <div class="col-12 col-lg-3 ">
                                            <input type="password" maxlength="100" class="form-control" name="respool_password"
                                                value="{#data.respool_password || ''#}" placeholder="token / password"
                                                required disabled>
                                            <div class="invalid-tooltip">
                                                请填写资源池密码！
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            备注/描述</label>
                                        <div class="col-12 col-lg-6">
                                            <textarea name="description" placeholder="请输入详细内容"
                                                class="form-control input-md" rows="8" maxlength="200"
                                                required></textarea>
                                            <div class="invalid-tooltip">
                                                描述内容不能为空！
                                            </div>

                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right"></label>
                                        <div class="col-12 col-lg-6">
                                            <button class="btn btn-primary">提交</button>
                                        </div>
                                    </div>





                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </main>
        <!-- END Page Content -->
    </div>
    <!-- END Page Wrapper -->
    <!-- LOST END Quick Menu -->
    {#include template="include/color-profile"/#}
    <script src="js/vendors.bundle.js"></script>
    <script src="js/app.bundle.js"></script>


    {#'<script>var description = '+ JSON.stringify(data.description||"") +';</script>'#}

    <script>

        $('textarea').val(description);
        description = null;// 内容字段可能比较大，此处从内存中清除该变量

        $(function () {
            $('form').on('uim-submit', function (event, param) {
                // param.data.content = container.getContent();
                param.data.auto_deploy = $(this).is(':checked') ? 1 : 0;
                uim.api.emit({
                    code: "{#data.respool_id ? 'respool.edit' : 'respool.create'#}",
                    data: param.data,
                    success: function (data) {
                        parent.toastr.success('创建成功')
                        initApp.playSound('media/sound', 'voice_on')
                        setTimeout(function () {
                            uim.view('respool/list', {}, window);
                        }, 1000);
                    },
                    error: function (err) {

                    }
                });
            });
            $('#auto_deploy').click(function () {
                if ($(this).is(':checked')) {
                    $('.need_auto_deploy input').attr('disabled', false).attr('required', true);
                } else {
                    $('.need_auto_deploy input').attr('disabled', true).attr('required', false);
                }
            }).click().click();
        })


    </script>

    {#include template="include/common"/#}


</body>

</html>